public open class X : A() {
    public override fun foo() {

    }
}

public class Y : X() {
    public override fun foo() {

    }
}

public class Z : B() {
    public override fun foo() {

    }
}